const { queryDatabase } = require('../queue-client');

// 获取未下发的任务
async function getUnissuedTasks() {
  try {
    const sql = `
      SELECT * FROM TaskList 
      WHERE is_issued = 0
      ORDER BY Unload_Line, Unload_Col, Unload_Layer
    `;
    
    const rows = await queryDatabase(sql);
    console.log(`🔍 查询未下发任务，返回 ${rows.length} 条记录`);
    return rows;
  } catch (error) {
    console.error('获取未下发任务失败:', error);
    throw error;
  }
}

module.exports = {
  getUnissuedTasks
};